package com.abluedog;

import com.abluedog.config.ModConfig;
import com.abluedog.event.PlayerConnectionCallBack;
import com.abluedog.player.PlayerData;
import com.abluedog.state.BreakBlocksCountLoaderAndSaver;
import net.fabricmc.api.ModInitializer;

import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.ActionResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.Path;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class RandomSurvival implements ModInitializer {
    public static final Logger LOGGER = LoggerFactory.getLogger("random-survival");
	public static final String MOD_ID = "random_survival";

	@Override
	public void onInitialize() {
		PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> {
			PlayerData playDate = BreakBlocksCountLoaderAndSaver.getPlayDate(player);
			playDate.addBreaksCount();
			playDate.updateScoreboard();
			return ActionResult.SUCCESS.isAccepted();
        });
		PlayerConnectionCallBack.After.register((connection, player, clientData) -> {
			PlayerData playDate = BreakBlocksCountLoaderAndSaver.getPlayDate(player);
			playDate.createScoreboard(player);
		});
		ModConfig.init();
	}
}
